import { _decorator, Color, Component, Label, Node } from 'cc';
import { Report, SideType } from '../entity/Report';

import { MapZone } from '../entity/MapZone';
import { reportInfo_SendRes } from '../entity/reportInfo_SendRes';
import { reportInfo_SendHelp } from '../entity/reportInfo_SendHelp';
import { ColorEnum } from '../entity/ColorEnum';
const { ccclass, property } = _decorator;

@ccclass('UserVillage')
export class UserVillage extends Component {
    @property(Label)
    userTittle: Label
    @property(Label)
    villageTittle: Label
    @property(Label)
    user: Label
    @property(Label)
    village: Label

    start() {

    }

    setData(report: Report, side: SideType) {
        if (side == SideType.Attack) {
            this.userTittle.string = '进攻方'
            this.userTittle.color = new Color(ColorEnum.Red)
            this.villageTittle.string = '出兵村庄'
            this.user.string = report.srcUserName
            let xy = MapZone.getXyByZoneId(report.OriZoneId)
            this.village.string = `${report.OriZoneName}(${xy[0]}|${xy[1]})`
        } else {
            this.userTittle.string = '防守方'
            this.userTittle.color = new Color(ColorEnum.Blue)
            this.villageTittle.string = '防守村庄'
            this.user.string = report.dstUserName
            let xy = MapZone.getXyByZoneId(report.SimZoneId)
            this.village.string = `${report.SimZoneName}(${xy[0]}|${xy[1]})`
        }
    }

    setRes(report: Report, info: reportInfo_SendRes) {
        this.userTittle.string = '运出村庄'
        this.userTittle.color = new Color(ColorEnum.Green)
        this.villageTittle.string = '接受村庄'
        let xy = MapZone.getXyByZoneId(report.OriZoneId)
        this.user.string = `${report.OriZoneName}(${xy[0]}|${xy[1]})`

        xy = MapZone.getXyByZoneId(report.SimZoneId)
        this.village.string = `${report.SimZoneName}(${xy[0]}|${xy[1]})`
    }

    setHelp(report: Report){
        this.userTittle.string = '出兵村庄'
        this.userTittle.color = new Color(ColorEnum.Green)
        this.villageTittle.string = '驻守村庄'

        let xy = MapZone.getXyByZoneId(report.OriZoneId)
        this.user.string = `${report.OriZoneName}(${xy[0]}|${xy[1]})`

        xy = MapZone.getXyByZoneId(report.SimZoneId)
        this.village.string = `${report.SimZoneName}(${xy[0]}|${xy[1]})`
    }
}


